import { Request, Response } from 'express';

const generateDataSource = (req: Request, res: Response) => {
  const params = req.query;
  const { value } = params;
  const dataSource = [{
    title: '话题',
    children: [{
      title: `${value}`,
      count: 10000,
    }, {
      title: `${value} UI`,
      count: 10600,
    }],
  }, {
    title: '问题',
    children: [{
      title: `${value} 有什么`,
      count: 60100,
    }, {
      title: `${value} 是什么`,
      count: 30010,
    }],
  }, {
    title: '文章',
    children: [{
      title: `有关${value}的一百个问题与回答`,
      count: 100000,
    }],
  }];
  res.json(!value ? [] : dataSource);
};

export default {
  'GET /_api/auto-complete-certain-category': generateDataSource,
};